package org.brownflat.lighthouse.web;

import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.integration.spring.SpringBean;
import org.apache.log4j.Logger;
import org.brownflat.lighthouse.monitoring.device.DeviceService;

/**
 * <p>&copy Rupert Jones 2012</p>
 *
 * @author rup
 */
public class ManualDeviceAction extends AbstractAction{

    private static final Logger LOG = Logger.getLogger(ManualDeviceAction.class);
    @SpringBean
    private DeviceService deviceService;

    @DefaultHandler
    public Resolution view() {
        String action = getContext().getRequest().getParameter("action");
        if("broken".equals(action)) {
            deviceService.broken();
        } else if ("notbroken".equals(action)) {
            deviceService.notBroken();
        } else {
            deviceService.reset();
        }
        return getForwardJSPResolution("manual.jsp");
    }
}
